package com.red.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.red.entity.Account;
import com.red.entity.UserRole;
import com.red.result.Result;
import com.red.service.UserRoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/role")
public class UserRoleController {
    @Autowired
    private UserRoleService userRoleService;

    @ApiOperation("根据条件查询权限")
    @GetMapping("/select")
    public Result findAll(Integer id){
        return new Result(
                userRoleService.list(
                        new QueryWrapper<UserRole>()
                                .like(id!=null,"id",id)
                )
        );
    }
    @ApiOperation("添加权限")
    @PostMapping("/save")
    public Result save(UserRole userRole){
        return new Result(userRoleService.save(userRole));
    }
}
